//package cc.comac.mom.datahandlers.entity;
//
//import java.time.LocalDateTime;
//import java.util.ArrayList;
//import java.util.Collection;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//import org.springframework.transaction.annotation.Transactional;
//
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
//import com.baomidou.mybatisplus.core.metadata.IPage;
//import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
//import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
//
//import cc.comac.mom.bean.QualityAsrFeatures;
//import cc.comac.mom.dao.entity.EquipAsrFeaturesDao;
//import cc.comac.mom.entity.EquipAsrFeaturesEntity;
//import cc.comac.mom.util.BaseEntityDataUtil;
//import cc.comac.mom.util.GetGeneralFieldValue;
//
//@Component
//@Transactional
//public class EquipAsrFeaturesDataHandler extends ServiceImpl<EquipAsrFeaturesDao, EquipAsrFeaturesEntity>{
//	@Autowired
//	private EquipAsrFeaturesDao equipAsrFeaturesDao;
//	@Autowired
//	private BaseEntityDataUtil baseEntityDataUtil;
//	/**
//	 * 批量导入
//	 * @param equipAsrFeaturesList
//	 * @return
//	 */
//	public int insertBatch(List<QualityAsrFeatures> equipAsrFeaturesList) {
//		// 保存数据
//		if(equipAsrFeaturesList==null || equipAsrFeaturesList.size()<1) {
//			throw new RuntimeException("未检测到数据！");
//		}
//		for(QualityAsrFeatures equipAsrFeatures:equipAsrFeaturesList)
//		{
//			baseEntityDataUtil.setBaseEntityData(equipAsrFeatures);
//		}
//		Integer insert = equipAsrFeaturesDao.insertAsrFeaturesBatch(equipAsrFeaturesList);
//		return insert;
//	}
//	/**
//	 * 分页查询
//	 * 
//	 * @param equipParamItem
//	 * @return
//	 */
//	public QualityAsrFeatures selectAllByPage(QualityAsrFeatures equipAsrFeatures) {
//		QualityAsrFeatures returnEquipAsrFeatures = new QualityAsrFeatures();
//		if(equipAsrFeatures.getPageNum()==null || equipAsrFeatures.getPageNum()==0) {
//			equipAsrFeatures.setPageNum(1L);
//		}
//		if(equipAsrFeatures.getPageSize()==null || equipAsrFeatures.getPageSize()==0) {
//			equipAsrFeatures.setPageSize(10L);
//		}
//		
//		QueryWrapper<EquipAsrFeaturesEntity> queryWrapper = new QueryWrapper<EquipAsrFeaturesEntity>();
//		queryWrapper.eq("row_status", 1);
//		if(equipAsrFeatures.getPartNumber()!=null && !"".equals(equipAsrFeatures.getPartNumber())) {
//			queryWrapper.like("part_number", equipAsrFeatures.getPartNumber());
//		}
//		if(equipAsrFeatures.getFeatures()!=null && !"".equals(equipAsrFeatures.getFeatures())) {
//			queryWrapper.like("features", equipAsrFeatures.getFeatures());
//		}
//		if(equipAsrFeatures.getSize()!=null && !"".equals(equipAsrFeatures.getSize())) {
//			queryWrapper.like("size", equipAsrFeatures.getSize());
//		}
//		if(equipAsrFeatures.getInitialReliabilityValue()!=null && !"".equals(equipAsrFeatures.getInitialReliabilityValue())) {
//			queryWrapper.like("initial_reliability_value", equipAsrFeatures.getInitialReliabilityValue());
//		}
//		if(equipAsrFeatures.getGrade()!=null && !"".equals(equipAsrFeatures.getGrade())) {
//			queryWrapper.like("grade", equipAsrFeatures.getGrade());
//		}
//		// 不返回总记录数 设置false
//		Page<EquipAsrFeaturesEntity> page = new Page<>(equipAsrFeatures.getPageNum(), equipAsrFeatures.getPageSize(), true);
//		IPage<EquipAsrFeaturesEntity> iPage = equipAsrFeaturesDao.selectPage(page, queryWrapper);
//		List<EquipAsrFeaturesEntity> records = iPage.getRecords();
//		returnEquipAsrFeatures.setPageNum(equipAsrFeatures.getPageNum());
//		returnEquipAsrFeatures.setPageSize(equipAsrFeatures.getPageSize());
//		returnEquipAsrFeatures.setEntityList(records);
//		returnEquipAsrFeatures.setTotalQuantity(iPage.getTotal());
//		returnEquipAsrFeatures.setPageCount(iPage.getPages());
//		return returnEquipAsrFeatures;
//	}
//	/**
//	 * 添加ASR特征库
//	 * @param equipAsrFeatures
//	 * @return
//	 */
//	public int insert(QualityAsrFeatures equipAsrFeatures) {
//		Map<String, Object> map = new HashMap<String, Object>();
//		// 校验参数组编码是否重复
//		map.put("row_status", 1);
//		map.put("part_number", equipAsrFeatures.getPartNumber());
//		map.put("features", equipAsrFeatures.getFeatures());
//		map.put("size", equipAsrFeatures.getSize());
//		map.put("initial_reliability_value", equipAsrFeatures.getInitialReliabilityValue());
//		map.put("grade", equipAsrFeatures.getGrade());
//		map.put("features_count", equipAsrFeatures.getFeaturesCount());
//		List<EquipAsrFeaturesEntity> selectInfo = equipAsrFeaturesDao.selectByMap(map);
//		if (selectInfo!=null && selectInfo.size() > 0) {
//			throw new RuntimeException("添加失败，已存在相同数据！");
//		}
//		baseEntityDataUtil.setBaseEntityData(equipAsrFeatures);
//		Integer insert = equipAsrFeaturesDao.insert((EquipAsrFeaturesEntity) equipAsrFeatures);
//		return insert;
//	}
//	/**
//	 * 修改ASR特征库
//	 * @param equipAsrFeatures
//	 * @return
//	 */
//	public int update(QualityAsrFeatures equipAsrFeatures) {
//		Map<String, Object> map = new HashMap<String, Object>();
//		// 校验参数组编码是否重复
//		map.put("row_status", 1);
//		map.put("part_number", equipAsrFeatures.getPartNumber());
//		map.put("features", equipAsrFeatures.getFeatures());
//		map.put("size", equipAsrFeatures.getSize());
//		map.put("initial_reliability_value", equipAsrFeatures.getInitialReliabilityValue());
//		map.put("grade", equipAsrFeatures.getGrade());
//		map.put("features_count", equipAsrFeatures.getFeaturesCount());
//		List<EquipAsrFeaturesEntity> selectInfo = equipAsrFeaturesDao.selectByMap(map);
//		if (selectInfo!=null && selectInfo.size() > 0 && equipAsrFeatures.getId()!=selectInfo.get(0).getId()) {
//			throw new RuntimeException("修改失败，已存在相同数据！");
//		}
//		equipAsrFeatures.setLastModifiedTime(LocalDateTime.now());
//		equipAsrFeatures.setLastModifier(GetGeneralFieldValue.getCurrentUser());
//		Integer insert = equipAsrFeaturesDao.updateById((EquipAsrFeaturesEntity) equipAsrFeatures);
//		return insert;
//	}
//	/**
//	 * 批量删除ASR特征库
//	 * @param equipAsrFeaturesList
//	 * @return
//	 */
//	public int batchDelete(List<QualityAsrFeatures> equipAsrFeaturesList) {
//		List<EquipAsrFeaturesEntity> list = new ArrayList<EquipAsrFeaturesEntity>();
//		// 预留删除校验
//		for (QualityAsrFeatures equipAsrFeatures : equipAsrFeaturesList) {
//			EquipAsrFeaturesEntity equipAsrFeaturesEntity = new EquipAsrFeaturesEntity();
//			equipAsrFeaturesEntity.setId(equipAsrFeatures.getId());
//			equipAsrFeaturesEntity.setRowStatus(0);
//			equipAsrFeaturesEntity.setLastModifiedTime(GetGeneralFieldValue.getLocalDateTime());
//			equipAsrFeaturesEntity.setLastModifier(GetGeneralFieldValue.getCurrentUser());
//			list.add(equipAsrFeaturesEntity);
//		}
//		// 批量更新数据
//		boolean updateBatchById = updateBatchById(list);
//		return updateBatchById ? 1 : 0;
//	}
//	/**
//	 * 批量更新
//	 * @param entityList
//	 * @return
//	 */
//	@Override
//	public boolean updateBatchById(Collection<EquipAsrFeaturesEntity> entityList) {
//		return super.updateBatchById(entityList);
//	}
//}
